package com.cuit.mapper;

import com.cuit.pojo.Comment;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Select("select * from comment where article_id=#{articleId}")
    public List<Comment> findCommentByArticleId(int articleId);
    @Select("select * from comment where id = #{id}")
    public Comment findById(int id);
    @Delete("delete from comment where id = #{id}")
    public int deleteById(int id);
    @Insert("insert into comment(id, text, like_num, dislike_num, created_date, user_id, article_id) values (#{id},#{text},#{likeNum},#{dislikeNum},#{createdDate},#{userId},#{articleId})")
    public int insertComment(Comment comment);
    @Update("update comment set text = #{text},like_num=#{likeNum},dislike_num=#{dislikeNum},created_date=#{createdDate},user_id=#{userId},article_id=#{articleId} where id=#{id}")
    public int updateById(Comment comment);
}
